.TH initdir 5
'''
.SH NAME
{/etc/initdir}/* - \fBinit\fR(8) service files.
'''
.SH DESCRIPTION
Service files provide an alternative to \fBinittab\fR(5) for
describing init process entries. Whereas inittab has one line
per entry in a single file, initdir uses one file for each entry. 
.P
Init treats initdir entries as if they were appended to inittab, that
is, they are started last and stopped first. Unlike inittab, initdir
lacks any fixed entry ordering; in particular, entries are not sorted
by name.
.P
Service files are simple text files or shell scripts, possibly
containing \fIrunlevels\fR mask field similar to inittab lines.
The (base)name of the file stands for \fIname\fR field of the entry.
The \fIcommand\fR is either the contents of the file, or (in case of
executable shell scripts) the full file path.
.P
Initdir entries are always \fBS\fR-type.
See \fBinittab\fR(5) for detailed description of entry types and runlevels.
'''
.SH SYNTAX
There are two slightly different flavors of service files.
The first one is a plain file:
.P
.EX
    \fB#:\fIrunlevels\fR
    \fIcommand arg arg arg\fR ...
.EE
.P
which gets the same treatment as any \fBinittab\fR(5) line.
In particular, \fIcommand\fR is parsed and stored 
the same way it is done with inittab entries.
.P
The second is a script (shell or otherwise):
.P
.EX
    \fB#!\fIinterpreter\fR
    \fB#:\fIrunlevels\fR
    \fIinterpreter-code\fR
    \fIinterpreter-code\fR
    \fIinterpreter-code\fR
.EE
.P
Files or this kind must be executable, and init will use the full file
path as the command to run. Only \fIrunlevels\fR are parsed by init in this
case, the rest is left to \fIinterpreter\fR.
.P
In both cases, \fB#:\fIrunlevels\fR line may be omitted.
'''
.SH USAGE
Service files are meant primarily for package-managed systems as a easy
way to add managed init entries, as opposed to modifying inittab each time
a package is installed or uninstalled.
.P
Scripts may also be useful for daemons that need external initialization code.
.P
Whenever a script is used, it should typically end with an \fBexec\fR(3) call
or some equivalent thereof to replace \fIinterpreter\fR with the actual daemon
process. Leaving \fIinterpreter\fR running only makes sense if there is some
cleanup to do after the daemon dies.
'''
.SH COMPATIBILITY
Service files used by {INIT} are not compatible with SysV \fBinitscript\fR(5)s.
Typical initscript is expected to spawn a child process and return immediately,
similar to \fBdaemon\fR(3) behavior which they often use. In contrast, a service
script spawns (or execs) a foreground process and remains running until the process
dies.
'''
.SH SEE ALSO
\fBinit\fR(8), \fBtelinit\fR(8), \fBinittab\fR(5)
